﻿<UserControl x:Class="navigation.Contents.ScrumBoardScreen"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:s="http://schemas.microsoft.com/surface/2008"
             xmlns:content="clr-namespace:navigation.Contents"
             xmlns:data="clr-namespace:navigation.Data"
             xmlns:control="clr-namespace:navigation.Controls"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             mc:Ignorable="d"
             x:Name="ScrumBoard">
    
    <UserControl.Resources>

        <DataTemplate x:Key="ScrumBoardItemTemplate" DataType="{x:Type data:UserStory}">            
            <Grid MinHeight="200">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200" Name="StoryCardColumn"/>
                    <ColumnDefinition Width="*" Name="Column1"/>
                    <ColumnDefinition Width="*" Name="Column2"/>
                    <ColumnDefinition Width="*" Name="Column3"/>
                </Grid.ColumnDefinitions>
                <Border BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="1" Grid.Column="0" Grid.Row="0"/>
                <Border BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="1" Grid.Column="1" Grid.Row="0"/>
                <Border BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="1" Grid.Column="2" Grid.Row="0"/>
                <Border BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="1" Grid.Column="3" Grid.Row="0"/>

                <Grid Grid.Column="0" AllowDrop="False">
                    <Grid Width="160" Height="130" HorizontalAlignment="Center" VerticalAlignment="Center">
                        <Rectangle Name="Rect" RadiusY="2.5" RadiusX="2.5" Height="150" Width="180" Margin="-7,0,-9,-12" Fill="{Binding StoryCardColor}"/>

                        <RichTextBox Name="TextBox" Margin="8,52,8,0" FontSize="10" Background="{Binding StoryCardColor}" Foreground="White">
                            <FlowDocument>
                                <Paragraph>
                                    <Run Text="{Binding StoryContent, Mode=OneWay}"/>
                                </Paragraph>
                            </FlowDocument>
                        </RichTextBox>
                        <Label Name="StoryLabel" Content="{Binding StoryName}" HorizontalAlignment="Left" Margin="8,8,0,0" VerticalAlignment="Top" Width="148" Height="30" Foreground="White" FontSize="15" FontStyle="Italic" FontFamily="Arial" />
                    </Grid>
                </Grid>
                <control:ScrumBoardTasksContainer Grid.Column="1" Tag="PlannedBox" Items="{Binding Planned}" StoryName="{Binding StoryName}"/>
                <control:ScrumBoardTasksContainer Grid.Column="2" Tag="InProgressBox" Items="{Binding InProgress}" StoryName="{Binding StoryName}"/>
                <control:ScrumBoardTasksContainer Grid.Column="3" Tag="DoneBox" Items="{Binding Done}" StoryName="{Binding StoryName}"/>
            </Grid>
        </DataTemplate>

        <Style x:Key="CursorStyle" TargetType="{x:Type ContentControl}">
            <Setter Property="ContentTemplate" Value="{StaticResource ScrumBoardItemTemplate}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ContentControl}">
                        <Border BorderBrush="White" BorderThickness="1">
                            <ContentPresenter
                                Content="{TemplateBinding Content}" 
                                ContentTemplate="{TemplateBinding ContentTemplate}">
                            </ContentPresenter>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="ListBoxItem" x:Key="ContainerStyle">
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border Name="Border" SnapsToDevicePixels="true">
                            <ContentPresenter Margin="0"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid HorizontalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="AUTO"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" Name="StoryCardColumn"/>
                <ColumnDefinition Width="*" Name="Column1"/>
                <ColumnDefinition Width="*" Name="Column2"/>
                <ColumnDefinition Width="*" Name="Column3"/>
            </Grid.ColumnDefinitions>

            <Border BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="1" Grid.Column="0" Grid.Row="0"/>
            <Border BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="1" Grid.Column="1" Grid.Row="0"/>
            <Border BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="1" Grid.Column="2" Grid.Row="0"/>
            <Border BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="1" Grid.Column="3" Grid.Row="0"/>

            <s:SurfaceButton Content="Story Card" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Verdana" FontSize="16" FontWeight="Bold" Foreground="White" Background="Transparent"/>
            <s:SurfaceButton Name="PlannedButton" Content="Planned" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Verdana" FontSize="16" FontWeight="Bold" Foreground="White" Background="Transparent" Click="PlannedButton_Click" />
            <s:SurfaceButton Name="InProgressButton" Content="In Progress" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Verdana" FontSize="16" FontWeight="Bold" Foreground="White" Background="Transparent" Click="InProgressButton_Click"/>
            <s:SurfaceButton Name="DoneButton" Content="Done" Grid.Column="3" Grid.Row="0" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Verdana" FontSize="16" FontWeight="Bold" Foreground="White" Background="Transparent" Click="DoneButton_Click"/>
        </Grid>

        <Grid Grid.Row="1" Name="scrollArea">
            <!--<s:SurfaceScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden" Height="{Binding ElementName=scrollArea, Path=ActualHeight}" s:TouchExtensions.HoldGesture="SurfaceScrollViewer_HoldGesture">
                <StackPanel Name="sp" AllowDrop="True" Background="Transparent" >
                    <ItemsControl ItemsSource="{Binding ElementName=ScrumBoard, Path=ScrumBoardItems}" ItemTemplate="{StaticResource ScrumBoardItemTemplate}"/>
                </StackPanel>
            </s:SurfaceScrollViewer>-->

            <s:SurfaceListBox Name="sp" AllowDrop="True" Margin="0" Height="{Binding ElementName=scrollArea, Path=ActualHeight}" Width="{Binding ElementName=scrollArea, Path=ActualWidth}" ItemContainerStyle="{StaticResource ContainerStyle}" Background="Transparent"
                              ItemsSource="{Binding ElementName=ScrumBoard, Path=ScrumBoardItems}" ItemTemplate="{StaticResource ScrumBoardItemTemplate}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Hidden"
                              
                              s:TouchExtensions.HoldGesture="sp_HoldGesture"
                              s:SurfaceDragDrop.Drop="sp_Drop"
                              s:SurfaceDragDrop.DragCompleted="sp_DragCompleted"
                              s:SurfaceDragDrop.DragCanceled="sp_DragCanceled">
            </s:SurfaceListBox>
        </Grid>

    </Grid>
</UserControl>
